package cn.com.thingo.hyintelligent.presenter;

import javax.inject.Inject;

import cn.com.thingo.hyintelligent.base.RxPresenter;
import cn.com.thingo.hyintelligent.base.contract.EzWifiApConfigContract;
import cn.com.thingo.hyintelligent.model.DataManager;
import cn.com.thingo.hyintelligent.model.bean.BaseBean;
import cn.com.thingo.hyintelligent.model.bean.EzAddDevicePermissionBean;
import cn.com.thingo.hyintelligent.model.bean.EzDeviceStateBean;
import cn.com.thingo.hyintelligent.util.LogUtil;
import cn.com.thingo.hyintelligent.util.RxUtil;
import io.reactivex.functions.Consumer;

public class EzWifiApConfigPresenter extends RxPresenter<EzWifiApConfigContract.View> implements EzWifiApConfigContract.Present {
    private DataManager dataManager;

    @Inject
    public EzWifiApConfigPresenter(DataManager dataManager) {
        this.dataManager = dataManager;
    }


    @Override
    public void addEzDevicePermission(String accessToken, String tel, String toTel, String statement) {
        addSubscribe(dataManager.addEzDevicePermission(accessToken, tel, toTel, statement).compose(RxUtil.<BaseBean>rxSchedulerHelper()).subscribe(new Consumer<BaseBean>() {
            @Override
            public void accept(BaseBean bean) throws Exception {
                mView.viewAddEzDevicePermissionResult(bean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtil.e(throwable.getMessage());
            }
        }));
    }
}
